package de.nroz.view;

import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;

public class TextDocument extends PlainDocument
{

	/**
	 * 
	 */
	private static final long serialVersionUID = -6502718497331342896L;
	
	private int textLimit = 0;
	
	public TextDocument(int limit)
	{
		this.textLimit = limit;
	}
	
	public void insertString(int offs, String str, AttributeSet a) throws BadLocationException
	{
		int length = getLength() + str.length(); 
		if(length > textLimit)
		{
			return;
		}
		super.insertString(offs, str, a);
	}
}
